<?php get_header(); ?>

  <div class="content">
	<div class="nav-tips">
		首页 > 在线报名
	</div>
    <div class="reg_wrapper">
      <form method="post" action="player_reg.php" >
			<div id="step1">
		    	<div class="player">填写人</div>
				<p class="teacher"><input type="radio" name="player_id" value="1"/> 指导老师</p>
				<p class="parent"><input type="radio" name="player_id" value="2"/> 家长</p>
				<p class="button"><input type="button" name="next" value="下一步"  class="submit"/></p>
		   </div>
		   <div id="step2">
				<div class="reg-t">请认真填写以下内容</div>
				<p>
				<span class="reg-sp" style="margin-left:95px">组别：</span><input type="radio" name="group_id" value="1">宝宝组&nbsp;
				<input type="radio" name="group_id" value="2">幼儿组&nbsp;
				<input type="radio" name="group_id" value="3">少儿组&nbsp;
				<input type="radio" name="group_id" value="5">团体组
				</p>
				<p><span class="reg-sp">宝宝姓名：</span><input type="text" name="name" class="text"></p>
				<p><span class="reg-sp">姓名拼音：</span><input type="text" name="eng_name" class="text"></p>
				<p><span class="reg-sp" style="margin-left:-28px">性别：</span><input type="radio" name="sex" vaue="1">男孩&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sex" vaue="2">女孩</p>
				<p><span class="reg-sp" style="margin-left:30px">生日：</span><input type="text" name="birthday" class="text"></p>
				<p><span class="reg-sp" style="margin-left:30px">民族：</span><input type="text" name="nation" class="text"></p>
				<p><span class="reg-sp" style="margin-left:-30px">宝宝爱好、特长：</span><input type="text" name="hobby" class="text"></p>
				<p class="button"><input type="button" name="next" value="下一步"  class="submit"/></p>
				
		   </div>
		<div id="step3-1">
				<div class="reg-t">请指导老师认真填写以下内容</div>
				<p><span class="reg-sp" style="margin-left:-15px">幼儿园/学校：</span><input type="text" name="school" class="text"></p>
				<p><span class="reg-sp">所在班级：</span><input type="text" name="class" class="text"></p>
				<p style="margin-left:12px">
				省份：<select name="province">
				<option value="0" selected="selected">&nbsp;&nbsp;</option>
				<?php
					$province = $wpdb->get_results("SELECT * FROM wp_region WHERE parent_id = 1");
					foreach($province as $pro) {
						print('<option value="' . $pro->region_id . '">' . $pro->region_name . '</option>');
					}
				?>			
				</select>&nbsp;&nbsp;
				城市：<select name="city">
					<option value="0" selected="selected">&nbsp;&nbsp;</option>
				</select>
				</p>
				<p><span class="reg-sp">通讯地址：</span><input type="text" name="post" class="text"></p>
				<p><span class="reg-sp" style="margin-left:20px">邮编：</span><input type="text" name="postcode" class="text"></p>
				<p style="margin-top:30px;"><span class="reg-sp" style="margin-left:-30px">指导老师姓名：</span><input type="text" name="teacher" class="text"></p>
				<p style="margin-bottom:30px;"><span class="reg-sp">联系电话：</span><input type="text" name="teacher_phone" class="text"></p>
				<p><span class="reg-sp" style="margin-left:-15px">监护人姓名：</span><input type="text" name="parent_name" class="text"></p>
				<p><span class="reg-sp">联系电话：</span><input type="text" name="phone" class="text"></p>
				<p><span class="reg-sp">电子邮箱：</span><input type="text" name="email" class="text"></p>
				<p class="button"><input type="button" name="next" value="提交"  class="submit"/></p>
				
		   </div>
	
		<div id="step3-2">
				<div class="reg-t">请家长认真填写以下内容</div>
				<p><span class="reg-sp" style="margin-left:-15px">监护人姓名：</span><input type="text" name="parent_name" class="text"></p>
				<p><span class="reg-sp">联系电话：</span><input type="text" name="phone" class="text"></p>
				<p><span class="reg-sp">电子邮箱：</span><input type="text" name="email" class="text"></p>
				<p style="margin-left:12px">
				省份：<select name="province">
				<option value="0" selected="selected">&nbsp;&nbsp;</option>
				<?php
					$province = $wpdb->get_results("SELECT * FROM wp_region WHERE parent_id = 1");
					foreach($province as $pro) {
						print('<option value="' . $pro->region_id . '">' . $pro->region_name . '</option>');
					}
				?>			
				</select>&nbsp;&nbsp;
				城市：<select name="city">
					<option value="0" selected="selected">&nbsp;&nbsp;</option>
				</select>
				</p>
				<p><span class="reg-sp">通讯地址：</span><input type="text" name="post" class="text"></p>
				<p><span class="reg-sp" style="margin-left:30px">邮编：</span><input type="text" name="postcode" class="text"></p>
				<p class="button"><input type="button" name="next" value="提交"  class="submit"/></p>
				
		   </div>

		<div id="step4">
				<p><span style="margin-left:25px;">组别：</span><span id="group">宝宝组</span></p>
				<p><span>宝宝姓名：</span><span id="name">刘晓红</span></p>	
				<p><span style="margin-left:46px;">姓名拼音：</span><span id="eng_name">Liu Xiao Hong</span></p>
				<p><span style="margin-left:12px;">性别：</span><span id="sex">男孩<span></p>
				<p><span style="margin-left:50px;">生日：</span><span id="birthday">2006-06-06</span></p>
				<p><span style="margin-left:6px;">民族：</span><span id="nation">汉族<span></p>
				<p><span style="margin-left:-20px;">宝宝爱好、特长：</span><span id="hobby">唱歌、跳舞</span></p>
				<div id="school_info" style="margin-top:30px;margin-bottom:30px;display:none;">
				<p><span style="margin-left:-20px;">幼儿园/学校：</span><span id="school">洪恩幼教</span></p>	
				<p><span style="margin-left:-20px;">所在班级：</span><span id="class">洪恩幼教</span></p>
				<p><span style="margin-left:-20px;">通信地址：</span><span id="class">上地东路</span></p>	
				</div>
				<p><span style="margin-left:-17px;">监护人姓名：</span><span id="parent_name">刘大红</span></p>
				<p><span style="margin-left:30px;">联系电话：</span><span id="phone">13661255412</span></p>
				<p><span style="margin-left:70px;">电子邮件：</span><span id="email">lihong@hongen.com</span></p>
				<p><span style="margin-left:70px;">通讯地址：</span><span id="post">北京市海淀区上地东路</span></p>
				<p><span style="margin-left:14px;">邮编：</span><span id="group">100028</span></p>
				<p class="button"><input type="button" name="next" value="打印报名信息"  class="submit"/></p>
				<p class="button"><input type="button" name="next" value="下载报名信息"  class="submit"/></p>	

		</div>

      </form>
    </div>
  </div><!-- content -->
  <script type="text/javascript">
    $().ready(function() {
        $("input[name='birthday']").datepick({maxDate: new Date(), yearRange: 'c-15: c'});


		var player = 0;
		$("#step1 input[type='button']").click(function() {
			var sel_len = $("#step1 input:radio:checked").length;
			if(sel_len == 0) {
				alert("请选择填写人！");
				return;
			}
			player = $("#step1 input:radio:checked").val();
			goStep("#step2");
		
		});


		$("#step2 input[type='button']").click(function() {
			var error = false;
			var error_msg = "请完整填写报名信息，所有字段都是必填项。";
			var inps = $("#step2 input[type='text']");
			for (var i = 0; i < inps.length; i++) {
				if (inps[i].value == '') {
					error  = true;
					break;
				}
			}
			
			if($("#step2 input[name='group_id']:radio:checked").length == 0 || $("#step2 input[name='sex']:radio:checked").length == 0) {
				error = true;
			}
			if(error == true) {
				alert(error_msg);
				return;
			}
			goStep("#step3-"+player);
		});		



		$("#step3-1 input[type='button']").click(function() {
			var error = false;
			var error_blank = false;
			var error_msg = "";
			var msg_blank = "请完整填写报名信息，所有字段都是必填项。";
			var inps = $("#step3-1 input[type='text']");
			for (var i = 0; i < inps.length-3; i++) {
				if (inps[i].value == '') {
					error  = true;
					error_blank = true;
					break;
				}
			}
			
			if($("#step3-1 select[name='province']").val() == 0 || $("#step3-1 select[name='city']").val() == 0) {
				error = true;
				error_blank = true;
			}
			if ($("#step3-1 input[name='postcode']").attr("value").length != 6) {
				error = true;
				error_msg = error_msg + "\n" + "邮政编码格式不正确。";
			}


			if (error_blank) error_msg = msg_blank +  error_msg;
			if (error) {
				alert(error_msg);
				return;
			}
			goStep("#step4");
		});		



		$("#step3-2 input[type='button']").click(function() {
			var error = false;
			var error_blank = false;
			var error_msg = "";
			var msg_blank = "请完整填写报名信息，所有字段都是必填项。";
			var inps = $("#step3-2 input[type='text']");
			for (var i = 0; i < inps.length; i++) {
				if (inps[i].value == '') {
					error  = true;
					error_blank = true;
					break;
				}
			}
			
			if($("#step3-2 select[name='province']").val() == 0 || $("#step3-2 select[name='city']").val() == 0) {
				error = true;
				error_blank = true;
			}
			if ($("#step3-2 input[name='postcode']").attr("value").length != 6) {
				error = true;
				error_msg = error_msg + "\n" + "邮政编码格式不正确。";
			}
			var email = $("#step3-2 input[name='email']").attr("value");
			if (!email.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)) {
				error = true;
				error_msg = error_msg + "\n" + "电子信箱格式不正确。";
			}

			if (error_blank) error_msg = msg_blank +  error_msg;
			if (error) {
				alert(error_msg);
				return;
			}
			goStep("#step4");
		});

		$("select[name='province']").bind('change', function(){
			var pro_id = $(this).attr("value");
			$.get("player_reg.php", {act: "city", id: pro_id},
				function(ret) {
					var str = ret.replace(/<\\/g, '<');
					$("select[name='city']").html(str);
				}, "html");
		});
		
		$("input[name='teacher_phone']").bind('keyup', function() {
			this.value = this.value.replace(/[^\d\-]/g, '');
		});
		$("input[name='phone']").bind('keyup', function() {
			this.value = this.value.replace(/[^\d\-]/g, '');
		});

		$("input[name='postcode']").bind('keyup', function() {
			this.value = this.value.replace(/[^\d]/g, '');
		});




		function goStep(step) {
			$("#step1").css("display", "none");
			$("#step2").css("display", "none");
			$("#step3-1").css("display", "none");
			$("#step3-2").css("display", "none");
			$("#step4").css("display", "none");
			$(step).css("display", "block");			
		
		}



function generateHtml() {
    var $no_input = '<未输入>';
    $("#name").text($("input[name='name']").val() ? $("input[name='name']").val() : $no_input);
	$("#eng_name").text($("input[name='eng_name']").val() ? $("input[name='eng_name']").val() : $no_input);
    $sex = $("input[name='sex']:checked").attr("value");
    $("#sex").text($sex ? ($sex == '1' ? '男' : '女') : $no_input);
	$("#birthday").text($("input[name='birthday']").val() ? $("input[name='birthday']").val() : $no_input);
	$("#nation").text($("input[name='nation']").val() ? $("input[name='nation']").val() : $no_input);
	$("#hobby").text($("input[name='hobby']").val() ? $("input[name='hobby']").val() : $no_input);
}


 });








/*

        $("input[type='checkbox']").bind('click', function(e) {
            $("input[type='checkbox']").removeAttr("checked");
            if (!$(this).attr("checked")) {
                $(this).attr("checked", true);
            }
        });
        $("form").bind('submit', form_submit);
		$("select[name='province']").bind('change', function(){
			var pro_id = $(this).attr("value");
			$.get("player_reg.php", {act: "city", id: pro_id},
				function(ret) {
					var str = ret.replace(/<\\/g, '<');
					$("select[name='city']").html(str);
				}, "html");
		});
		/*
		$("input[name='idcard']").bind('keyup', function() {
			this.value = this.value.replace(/[^\dxX]/g, '');
	});
		$("input[name='phone']").bind('keyup', function() {
			this.value = this.value.replace(/[^\d\-]/g, '');
		});
		$("input[name='postcode']").bind('keyup', function() {
			this.value = this.value.replace(/[^\d]/g, '');
		});
    });

    function form_submit() {
        var error = false;
		var error_msg = '';
		var error_blank = false;
		var msg_blank = "请完整填写报名信息，所有字段都是必填项。";
        var group_id = -1;
        $("input[type='checkbox']").each(function(i) {
            if ($(this).attr("checked") == true) {
                group_id = i + 1;
            }
        });
        $("input[name='group_id']").attr("value", group_id);

		if (!$("input[name='name']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='eng_name']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if ($("select[name='sex']").attr("value") == 0) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='birthday']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='nation']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if ($("select[name='province']").attr("value") == 0) {
			error = true;
			error_blank = true;
		}
		if ($("select[name='city']").attr("value") == 0) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='school']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='post']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='postcode']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='parent']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='phone']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='idcard']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='email']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='teacher']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (!$("input[name='hobby']").attr("value")) {
			error = true;
			error_blank = true;
		}
		if (group_id == -1) {
			error = true;
			error_blank = true;
		}
		if ($("input[name='postcode']").attr("value").length != 6) {
			error = true;
			error_msg = error_msg + "\n" + "邮政编码格式不正确。";
		}
		var idcard = $("input[name='idcard']").attr("value");
		if (idcard.length != 15 && idcard.length != 18 && !idcard.match(/^(\d{15}|\d{17}[\dxX])$/)) {
			error = true;
			error_msg = error_msg + "\n" + "身份证号码格式不正确。";
		}
		var email = $("input[name='email']").attr("value");
		if (!email.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)) {
			error = true;
			error_msg = error_msg + "\n" + "电子信箱格式不正确。";
		}
		if (error_blank) error_msg = msg_blank +  error_msg;
        if (error) {
            alert(error_msg);
            return false;
        }
        return true;
    }
	*/
  </script>
<?php get_footer(); ?>
